//2009/07/30 10:31:34
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>

using namespace std;

struct info
{
    string name;
    int rank;
    vector<double> score;
    double sum;
};

bool cmpRank(const info &a, const info &b)
{
    if (a.rank < b.rank)
        return true;
    else if (a.rank == b.rank && a.sum > b.sum )
        return true;
	else if(a.rank == b.rank && a.sum == b.sum && (a.name.compare(b.name) < 0))
		return true;
    return false;
}

class ContestScore
{
public:
    vector <string> sortResults(vector <string> data)
    {
		vector<string> ret;
        ret.clear();
        sz = data.size();
		if(sz == 0)
		{
			return ret;
		}
        vector<info> v;
        v.clear();
        for (int i=0; i<sz; i++)
        {
            info t;
            t.rank = 0;
            t.sum = 0.0;
            stringstream ss(data[i]);
            ss >> t.name;
            double n;
            while (ss >> n)
            {
                t.score.push_back(n);
				t.sum += n;
            }
			v.push_back(t);
        }

        for (int i=0; i<v[0].score.size(); i++)
        {
            for(int j=0; j<sz; j++)
			{
				int cnt=0;
				for(int k=0; k<sz; k++)
				{
					if(j!=k && v[j].score[i] < v[k].score[i])
					{
						cnt ++;
					}
				}
				v[j].rank += cnt + 1;
			}
        }
        sort(v.begin(), v.end(), cmpRank);
        for (int i=0; i<sz; i++)
        {
            char temp[100];
            sprintf(temp, "%s %d %2.1lf", v[i].name.c_str(), v[i].rank, v[i].sum);
            ret.push_back(temp);
        }
        return ret;
    }
private:
    int sz;
};
